using Web.Model;

namespace Web.DataAccess.Mappings
{
	public class UserMapping : EntityMapping<User>
	{
		public UserMapping()
		{
			Map(x => x.DisplayName);
		    Map(x => x.IsAdmin);
			Map(x => x.Email).Unique();
			Map(x => x.NotificationEmail);
			Map(x => x.HideEmail);
			Component(x => x.Password, c =>
			                           	{
			                           		c.Map(x => x.Hash);
			                           		c.Map(x => x.Salt);
			                           	});
            
			Map(x => x.Contacts);
			Map(x => x.Skills);
			Map(x => x.Interests);
			References(x => x.Avatar).Cascade.SaveUpdate();
			
            Map(x => x.Stars);
		    HasMany(x => x.Opinions).OrderBy("DateCreated DESC").Cascade.SaveUpdate();

            Map(x => x.NotifyOrganizerProjectCommented);
            Map(x => x.NotifyAuthorCommentReplied);
            Map(x => x.NotifyParticipantProjectUpcoming);

            Map(x => x.NotifyOrganizerUserApplied);
            Map(x => x.NotifyParticipantApplicationApproved);
            Map(x => x.NotifyOrganizerIdeaApproved);
            Map(x => x.NotifyAuthorNewsCommented);

            Map(x => x.AccountSourceId);
		}
	}
}